package com.wzu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzu.entity.Payment;
import com.wzu.mapper.PaymentMapper;
import com.wzu.service.PaymentService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class PaymentServiceImpl extends ServiceImpl<PaymentMapper, Payment> implements PaymentService {
    @Override
    public List<Payment> searchPayment(String insuredName, String cardId) {
        QueryWrapper<Payment> wrapper = new QueryWrapper<>();
        if (insuredName != null && !insuredName.isEmpty()) {
            wrapper.like("insured_name", insuredName);
        }
        if (cardId != null && !cardId.isEmpty()) {
            wrapper.like("card_id", cardId);
        }
        return list(wrapper);
    }
    @Override
    public boolean addPayment(Payment payment) {
        return save(payment);
    }
    @Override
    public boolean updatePayment(Payment payment) {
        return updateById(payment);
    }
    @Override
    public boolean deletePayment(Long id) {
        return removeById(id);
    }
} 